package com.tanggh.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import com.tanggh.dao.GenericDao;
import com.tanggh.service.GenericService;

@Service
public abstract class  GenericServiceImpl<M extends java.io.Serializable> implements GenericService<M> {

	protected GenericDao<M> genericDao;
	protected abstract void setGenericDao(GenericDao<M> genericDao);
	
	@Override
	public int countAll() {
		return genericDao.countAll();
	}

	@Override
	public void delete(Integer id) {
		genericDao.delete(id);
	}

	@Override
	public void deleteObject(M model) {
		genericDao.deleteObject(model);
	}

	@Override
	public boolean exists(Integer id) {
		return genericDao.exists(id);
	}

	@Override
	public M get(Integer id) {
		return genericDao.get(id);
	}

	@Override
	public List<M> listAll() {
		return genericDao.listAll();
	}

	@Override
	public void merge(M model) {
		genericDao.merge(model);
	}

	@Override
	public Integer save(M model) {
		System.out.println("GenericServiceImpl.save() genericDao:"+(genericDao==null));
		return genericDao.save(model);
	}

	@Override
	public void saveOrUpdate(M model) {
		genericDao.saveOrUpdate(model);
	}

	@Override
	public void update(M model) {
		genericDao.update(model);
	}

}
